import 'package:dio/dio.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/http/Dio.dart';

class DynamicService {
  static Future<DynamicResult?> getDynamicData(
      {Map<String, dynamic>? params}) async {
    var res = await HttpApi().get(
        url: Config.apiUrl['ApiList']['getDynamicData'],
        params: params,
        options: Options(extra: {'showLoading': false}));
    return DynamicEntity.fromJson(res).data;
  }

  static Future<dynamic> changeDynamicLike(
      {Map<String, dynamic>? params}) async {
    return await HttpApi().get(
        url: Config.apiUrl['ApiList']['changeDynamicLike'],
        params: params,
        options: Options(extra: {'showLoading': true}));
  }

  static Future<List<Tag>?> searchTag({Map<String, dynamic>? params}) async {
    var res = await HttpApi().get(
        url: Config.apiUrl['ApiList']['searchTag'],
        params: params,
        options: Options(extra: {'showLoading': false}));

    return res["data"] is String ? [] : TagEntity.fromJson(res).data;
  }

  static Future<dynamic> dynamicNew({Map<String, dynamic>? params}) async {
    return await HttpApi().get(
        url: Config.apiUrl['ApiList']['dynamicNew'],
        params: params,
        options: Options(extra: {'showLoading': true}));
  }

  static Future<DynamicDataEntity> dynamicInfo({Map<String,dynamic>? params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['dynamicInfo'],params: params,options:Options(extra:{'showLoading':false}));
    return DynamicDataEntity.fromJson(res['data']);
  }

  static Future<dynamic> changeDynamicCollection({Map<String,dynamic>? params}) async{
    return  await HttpApi().get(url: Config.apiUrl['ApiList']['changeDynamicCollection'],params: params,options:Options(extra:{'showLoading':true}));

  }
}
